const Random = require('mockjs').Random

export default {
    'get|/healthManage/trainBaseData': option => {
        return {
            status: 200,
            message: 'success',
            result: trainBaseData
        }
    },
    'post|/healthManage/trainScore': option=> {

        // console.log(trainScores)
        // console.log(option);
        // console.log(JSON.parse(option.body))
        // console.log(trainScores[JSON.parse(option.body).line][JSON.parse(option.body).train])

        return {
            status: 200,
            message: 'success',
            result: trainScores[JSON.parse(option.body).line][JSON.parse(option.body).train]
        }
    }
}

const trainBaseData = {
    'info': [{
        'id': 0,
        'line': 'XX01',
        'trains': [{
            'id': 0,
            'trainNum': '100000',
            'score': Random.natural(50, 100)
        }, {
            'id': 1,
            'trainNum': '100001',
            'score': Random.natural(50, 100)
        }, {
            'id': 2,
            'trainNum': '100002',
            'score': Random.natural(50, 100)
        }, {
            'id': 3,
            'trainNum': '100003',
            'score': Random.natural(50, 100)
        }, {
            'id': 4,
            'trainNum': '100004',
            'score': Random.natural(50, 100)
        }, {
            'id': 5,
            'trainNum': '100005',
            'score': Random.natural(50, 100)
        }, {
            'id': 6,
            'trainNum': '100006',
            'score': Random.natural(50, 100)
        }, {
            'id': 7,
            'trainNum': '100007',
            'score': Random.natural(50, 100)
        }, {
            'id': 8,
            'trainNum': '100008',
            'score': Random.natural(50, 100)
        }, {
            'id': 9,
            'trainNum': '100009',
            'score': Random.natural(50, 100)
        }, {
            'id': 10,
            'trainNum': '100010',
            'score': Random.natural(50, 100)
        }]
    }, {
        'id': 1,
        'line': 'XX02',
        'trains': [{
            'id': 0,
            'trainNum': '200000',
            'score': Random.natural(50, 100)
        }, {
            'id': 1,
            'trainNum': '200001',
            'score': Random.natural(50, 100)
        }, {
            'id': 2,
            'trainNum': '200002',
            'score': Random.natural(50, 100)
        }, {
            'id': 3,
            'trainNum': '200003',
            'score': Random.natural(50, 100)
        }, {
            'id': 4,
            'trainNum': '200004',
            'score': Random.natural(50, 100)
        }, {
            'id': 5,
            'trainNum': '200005',
            'score': Random.natural(50, 100)
        }, {
            'id': 6,
            'trainNum': '200006',
            'score': Random.natural(50, 100)
        }, {
            'id': 7,
            'trainNum': '200007',
            'score': Random.natural(50, 100)
        }]
    }]
}

// const trainScore = {
//     'scores4systems': [Random.natural(50, 100),
//         Random.natural(50, 100),
//         Random.natural(50, 100),
//         Random.natural(50, 100),
//         Random.natural(50, 100),
//         Random.natural(50, 100)],
//     'scores4systemsHistory': [Random.natural(50, 100),
//         Random.natural(50, 100),
//         Random.natural(50, 100),
//         Random.natural(50, 100),
//         Random.natural(50, 100),
//         Random.natural(50, 100)]
// }
let trainScores = [[], []]
for(let i = 0; i < 20; ++i) {
    let firstTrainScore = {
        'scores4systems': [Random.natural(50, 100),
            Random.natural(50, 100),
            Random.natural(50, 100),
            Random.natural(50, 100),
            Random.natural(50, 100),
            Random.natural(50, 100)],
        'scores4systemsHistory': [Random.natural(50, 100),
            Random.natural(50, 100),
            Random.natural(50, 100),
            Random.natural(50, 100),
            Random.natural(50, 100),
            Random.natural(50, 100)]
    }
    trainScores[0].push(firstTrainScore);

    let secondTrainScore = {
        'scores4systems': [Random.natural(50, 100),
            Random.natural(50, 100),
            Random.natural(50, 100),
            Random.natural(50, 100),
            Random.natural(50, 100),
            Random.natural(50, 100)],
        'scores4systemsHistory': [Random.natural(50, 100),
            Random.natural(50, 100),
            Random.natural(50, 100),
            Random.natural(50, 100),
            Random.natural(50, 100),
            Random.natural(50, 100)]
    }
    trainScores[1].push(secondTrainScore);
}

